package com.zhihu_lvliangi_android.option.zhengwu;

import java.util.ArrayList;
import java.util.List;

import com.android.widget.listview.pullload.PullLoadListView;
import com.zhihu_lvliangi_android.R;
import com.zhihu_lvliangi_android.R.id;
import com.zhihu_lvliangi_android.R.layout;
import com.zhihu_lvliangi_android.R.menu;
import com.zhihu_lvliangi_android.domain.CureRecord;
import com.zhihu_lvliangi_android.domain.NewItem;
import com.zhihu_lvliangi_android.domain.PlanModel;
import com.zhihu_lvliangi_android.option.general.GeneralWebviewActivity;
import com.zhihu_lvliangi_android.option.parent.ParentActivity;
import com.zhihu_lvliangi_android.option.zhengwu.adapter.EvluateListViewAdapter;
import com.zhihu_lvliangi_android.option.zhengwu.adapter.NewsListViewAdapter;
import com.zhihu_lvliangi_android.option.zhengwu.adapter.ProgressListViewAdapter;
import com.zhihu_lvliangi_android.util.Constant;

import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

/**
 * 在线评议
 * @author 徐宇健
 *
 */
public class GuideEvaluateActivity extends ParentActivity {

	private PullLoadListView mPullListView;
	private List<PlanModel> mPlans = new ArrayList<PlanModel>();;
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		int id = item.getItemId();
		if (id == android.R.id.home) {
			finish();
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	private void initActionBar() {
		ActionBar actionBar = getSupportActionBar();
		actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.action_bar));
		actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.setIcon(new BitmapDrawable());//不设置图标icon
	}

	@Override
	protected int getLayoutId() {
		return R.layout.activity_guide_progress;
	}



	@Override
	protected void setupViews() {
		initActionBar();
		PlanModel planModel = new PlanModel();
		planModel.setId(201510000133L);
		planModel.setName("机动车注册信息变更");
		planModel.setTitle("机动车注册、变更、抵押、转移、注销、登记");
		planModel.setDeclarationdate("2015-01-08");
		planModel.setThenotifier("张钧");
		planModel.setCompany("公安局交警支队");
		planModel.setCreateDate("2015-01-08");
		planModel.setUpdateDate("2015-01-09");
		planModel.setState("办结");
		mPlans.add(planModel);
		
		planModel = new PlanModel();
		planModel.setId(201510000415L);
		planModel.setName("职业资格证书核发");
		planModel.setTitle("职业资格证书核发");
		planModel.setDeclarationdate("2015-01-14");
		planModel.setThenotifier("张钧");
		planModel.setCompany("人力资源和社会保障局");
		planModel.setCreateDate("2015-01-14");
		planModel.setUpdateDate("2015-01-16");
		planModel.setState("受理");
		mPlans.add(planModel);
		
		mPullListView = (PullLoadListView) findViewById(R.id.news_item_ListView);
		mPullListView.setCanRefresh(true);
		EvluateListViewAdapter adapter = new EvluateListViewAdapter(this,mPlans);
		mPullListView.setAdapter(adapter);
		System.out.println(adapter.getCount());
		mPullListView.setOnItemClickListener(OnItemClickListener);
	}
	
	private OnItemClickListener OnItemClickListener = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			if (--arg2 >= 0) { // -- 下拉刷新bug，少了第一条数据}
			Intent intents = new Intent(GuideEvaluateActivity.this,EvaluateDetailActivity.class);
			intents.putExtra(Constant.GENERAL_SAVE_KEY,mPlans.get(arg2));
			startActivity(intents);
			}
		}
	};


	@Override
	protected void initialized() {
		// TODO Auto-generated method stub
		
	}



	@Override
	protected void threadTask() {
		// TODO Auto-generated method stub
		
	}
}
